package com.baidu.tcpChatDemo2;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;

public class ChartServer {
    public static ArrayList<Socket> sockets = new ArrayList<>();

    public static void main(String[] args) throws Exception {
        ServerSocket serverSocket = new ServerSocket(9191);

        while (true){
            Socket socket = serverSocket.accept();

            //有新的链接的话就将链接存入list
            ChartServer.sockets.add(socket);

            //有新链接就启动线程并接受消息
            ChartServerReaderThread chartServerReaderThread = new ChartServerReaderThread(socket);
            chartServerReaderThread.start();
        }
    }
}
